﻿CREATE PROC spObtenListaSoporte
AS
BEGIN
	SET NOCOUNT OFF;
	
	SELECT	s.IdSoporte ,
	        s.Asunto ,
	        s.FechaSoporte ,
	        s.IdEstatus ,
	        s.IdLaboratorio ,
	        l.Nombre AS NomLaboratorio,
	        s.IdSucursal ,
	        suc.Nombre AS NomSucursal
	FROM	dbo.Soporte				s
	INNER JOIN dbo.CatLaboratorio	l
	ON		s.IdLaboratorio = l.IdLaboratorio
	INNER JOIN dbo.CatSucursal		suc
	ON		s.IdLaboratorio = suc.IdLaboratorio
	AND		s.IdSucursal	= suc.IdSucursal
	WHERE	s.IdEstatus		= 1
	
	SELECT	COUNT(1) AS NuevoSoporte
	FROM	dbo.Soporte
	WHERE	IdEstatus		= 1
	AND		DATEADD(MINUTE, 1, FechaSoporte) >= GETDATE()
	
	SET NOCOUNT ON;
END
GO
